package com.shortLinked.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shortLinked.project.common.convention.result.Result;
import com.shortLinked.project.common.convention.result.Results;
import com.shortLinked.project.dto.req.RecoverRecycleBinReqDTO;
import com.shortLinked.project.dto.req.RecycleBinReqDTO;
import com.shortLinked.project.dto.req.RemoveRecycleBinReqDTO;
import com.shortLinked.project.dto.req.ShortLinkRecycleBinPageReqDTO;
import com.shortLinked.project.dto.resp.ShortLinkPageRespDTO;
import com.shortLinked.project.service.RecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短链接回收站控制层
 */
@RestController
@RequiredArgsConstructor
public class RecycleBinController {
    private final RecycleBinService recycleBinService;

    /**
     * 短链接回收站保存功能
     */
    @PostMapping("/api/short-link/recycle-bin/project/v1/save")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinReqDTO requestParam) {
        recycleBinService.saveRecycleBin(requestParam);
        return Results.success();
    }


    /**
     * 回收站短链接分页查询
     */
    @GetMapping("/api/short-link/recycle-bin/project/v1/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycleBinShortLink(ShortLinkRecycleBinPageReqDTO requestParam) {
        return Results.success(recycleBinService.pageRecycleBinShortlink(requestParam));
    }

    /**
     * 回收站短链接恢复功能
     */
    @PostMapping("/api/short-link/recycle-bin/project/v1/recover")
    public Result<Void> recoverRecycleBin(@RequestBody RecoverRecycleBinReqDTO requestParam) {
        recycleBinService.recoverRecycleBin(requestParam);
        return Results.success();
    }

    /**
     * 回收站短链接移除功能
     */
    @PostMapping("/api/short-link/recycle-bin/project/v1/remove")
    public Result<Void> recoverRecycleBin(@RequestBody RemoveRecycleBinReqDTO requestParam) {
        recycleBinService.removeRecycleBin(requestParam);
        return Results.success();
    }
}
